/**
 * 绘制辐射圆环
 * @param {Earth} options.earth 多边形的渲染容器
 * @param {Array} options.position 辐射中心位置 [ lng, lat, h ]
 * @param {Array} options.color 圆环颜色 colorArray
 * @param {Number} options.radius 圆环半径 
 * @param {Number} options.timeDuration 动画时长 秒
 * @param {Boolean} options.loopPlay 是否播放动画
 * @param {Boolean} options.changeStatus 是否可编辑属性
 * @param {object} options.data 临时数据存放
 * 
 * @methods update(options) 更新多边形数据
 * 
 * @returns {DrawScanLine} DrawScanLine实例  data自定义数据  XEObj属性XE实例  
 */

function DrawScanLine (options) {
    let radian = Math.PI / 180;
    let scanline = new XE.Obj.Scanline(options.earth);
    scanline.position = [
        options.position[0] * radian,
        options.position[1] * radian,
        options.position[2] || 1
    ]
    scanline.color = options.color || [ 0, 0, 1, 1 ]
    scanline.radius = options.radius || 10000
    scanline.timeDuration = options.timeDuration || 1
    scanline.loopPlay = options.loopPlay === undefined ? true : options.loopPlay
    scanline.playing = true
    scanline.show = options.show === undefined ? true : options.show

    scanline._node = this
    this.XEObj = scanline
    this.data = options.data || null
    this.changeStatus = options.changeStatus === undefined ? true : options.changeStatus
}

DrawScanLine.prototype.update = function (options) {
    if (!this.changeStatus) {
        return
    }
    for (let k in options) {
        this.XEObj[k] = options[k]
    }
}

DrawScanLine.prototype.destroy = function () {
    this.XEObj._node = null
    this.XEObj.destroy()
}

DrawScanLine.prototype.setShow = function (options) {
    this.XEObj.show = options
}


export default DrawScanLine